package org.ruanjj.io;

import org.junit.Test;

import java.io.*;

public class InputStreamReaderOutputStreamWriterMain {
    @Test
    public void test1() throws IOException {
        try(
                FileInputStream fi = new FileInputStream("abc.txt");
                InputStreamReader is = new InputStreamReader(fi,"UTF-8");
                BufferedReader br = new BufferedReader(is);

                FileOutputStream fo = new FileOutputStream("abc_iso.txt");
                OutputStreamWriter os = new OutputStreamWriter(fo,"UTF-8");
                BufferedWriter bw = new BufferedWriter(os)
                ){
            String data;
            while((data = br.readLine()) != null){
                bw.write(data);
                bw.newLine();
            }
        }

        System.out.println("编码转换成功");
    }
}
